const query = require("../db/connection");
// sql增
const userAddService = async (params)=>{
    const res =  await query(`insert into user(username,password,nickname,age,phone) values("${params.username}","${params.password}","${params.nickname}","${params.age}","${params.phone}")`);
    return res;
}
// sql删
const userdeleteService = async (params)=>{

    const res =  await query(`delete from user where(id="${params}")`)
    return true;
}
// sql改
const userupdataService = async (params)=>{

    const sql = `update user set username="${params.username}",password="${params.password}",nickname="${params.nickname}",age="${params.age}",phone="${params.phone}" where(id="${params.id}")`;
    const res = await query(sql);
    console.log(res);
    return res;
}
// sql查
const userselectService = async (params)=>{

    const sql = `select * from user`;
    const res = await query(sql);
    return res;
}
module.exports={
    userAddService,
    userdeleteService,
    userupdataService,
    userselectService,
}